<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/";
%>
<html>
    <head>
        <base href="<%=basePath%>">
        <link href="css/login.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="jquery/jquery-1.11.1-min.js"></script>
        <title>登录界面</title>
        <script type="text/javascript">
            $(function (){
                $("#login_bu").click(function (){
                    // 获取表单数据
                    var userAccount = $.trim($("#userAccount").val());
                    var userPassword = $.trim($("#userPassword").val());
                    var checkBtn = $("#checkBtn")[0].checked;
                    if(checkBtn==true){
                        // 发送请求
                        $.ajax({
                            url:"settings/qx/managerLogin.do",
                            data:{
                                adminAccount:userAccount,
                                adminPassword:userPassword
                            },
                            type:'post',
                            dataType:'json',
                            success:function (resp){
                                // 登录成功
                                if (resp.code==1){
                                    window.location.href="workbench/admin/adminLibrary.do";
                                }else{
                                    $("#tip").text(resp.message);
                                }
                            }
                        })
                    }else{
                        // 发送请求
                        $.ajax({
                            url:"settings/qx/userLogin.do",
                            data:{
                                userAccount:userAccount,
                                userPassword:userPassword
                            },
                            type:'post',
                            dataType:'json',
                            success:function (resp){
                                // 登录成功
                                if (resp.code==1){
                                    window.location.href="workbench/user/userLibrary.do";
                                }else{
                                    $("#tip").text(resp.message);
                                }
                            }
                        })
                    }
                })
            })
        </script>
    </head>
    <body>
        <div class="content">
            <div class="article">
                <div class="box">
                    <form action="#" method="post">
                        <div class="login">
                            <h2>用户登录<a href="settings/qx/user/toRegister.do">免费注册</a></h2>
                        </div>
                        <div class="item">
                            <label class="name"></label>
                            <input type="text" id="userAccount" name="id" required="required" placeholder="账号"/>
                        </div>
                        <div class="item">
                            <label class="pwd"></label>
                            <input type="password" id="userPassword" name="pwd" required="required" placeholder="密码"/>
                        </div>
                        <div class="checkcode">
                            <input type="checkbox" id="checkBtn" value="admin"/>
                            <!--点击超链接不跳转 执行函数 -->
                            <label for="checkBtn">管理员登录</label>
                            <font color="red"><span id="tip"></span></font>
                        </div>
                        <div class="button">
                            <input type="button" id="login_bu"  value="登录"/>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </body>
</html>
